/*package br.com.digicade.geosite.gpsavl.web.security;

import java.io.IOException;

import javax.inject.Singleton;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;

import com.google.inject.Inject;
import com.google.inject.Injector;

@Singleton
public class SecurityFilter implements Filter {
	
	private static final String[] PUBLIC_URLS = {"/security/*","/rest/security/*"};
	private static final String LOGIN_PAGE = "/security/login.jsp";
	
	private FilterConfig filterConfig = null;

	@Inject private Injector injector;


	@Override
	public void init(FilterConfig filterConfig) throws ServletException {
            this.filterConfig = filterConfig;
	}

	@Override
	public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
            DgSecurityContext cxt = injector.getInstance(DgSecurityContext.class);
            String uri = ((HttpServletRequest)request).getRequestURI();

            if(cxt.isSecure() || isPublicUrl(uri)) {
                chain.doFilter(request, response);
            } else {
                this.filterConfig.getServletContext().getRequestDispatcher(SecurityFilter.LOGIN_PAGE).forward(request, response);
            }
	}

	@Override
	public void destroy() {
	}

	private boolean isPublicUrl(String url) {
            for(String publicUrl : SecurityFilter.PUBLIC_URLS){
                if(publicUrl.endsWith("/*")) {
                    if(url.contains(publicUrl.replace("/*", ""))){
                        return true;
                    }
                } else {
                    if(url.equals(publicUrl)) {
                        return true;
                    }
                }
            }
            return false;
	}
	
}
*/